/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.view;

import PengendaliSuratDokumen.PengendaliSuratDokumen;
import PengendaliSuratDokumen.PengendaliTabel;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.sql.*;
import javax.print.DocFlavor.STRING;
import javax.swing.*;

/**
 *
 * @author Indrayanto
 */
public class Sekretariat extends JFrame {

    JFrame frame;
    JLabel background, logo, Sekertariat, universitas, surat, dokumen, nomor,
            perihal, asal, penerima, letak, loker, ruangan, lemari, namapetugas, tanggal, jenis;
    JTextField tnomor, tperihal, tasal, tpenerima, tnamapetugas,
            tloker, truangan, tlemari, tgl;
    JRadioButton rsurat, rdok;
    JButton cancel, save;
   
    File file;
    
    public Sekretariat() {
        frame = new JFrame();
        frame.setSize(730, 500);
        frame.setLocationRelativeTo(null);
        frame.setLayout(null);
        frame.setVisible(true);
        frame.setResizable(true);
        frame.setTitle("Panel Sekertariat");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


        rsurat = new JRadioButton("Surat");
        rsurat.setBounds(20, 175, 60, 22);
        rdok = new JRadioButton("Dokumen");
        rdok.setBounds(100, 175, 100, 22);
        ButtonGroup b = new ButtonGroup();
        b.add(rdok);
        b.add(rsurat);

        background = new JLabel(new ImageIcon("Background.jpg"));
        background.setBounds(0, 0, 800, 655);
        logo = new JLabel(new ImageIcon("sadar.png"));
        logo.setBounds(10, 10, 126, 124);
        //MEMBUAT JLABEL DAN MENSETTING FONT STYLE
        Sekertariat = new JLabel("Sekretariat");
        Sekertariat.setFont(new Font("Serif", Font.BOLD, 34));
        Sekertariat.setBounds(240, 20, 400, 40);
        Sekertariat.setForeground(Color.BLACK);
        universitas = new JLabel("Universitas Sanata Dharma");
        universitas.setFont(new Font("Serif", Font.BOLD, 30));
        universitas.setForeground(Color.BLACK);
        universitas.setBounds(150, 50, 400, 40);

        nomor = new JLabel("Nomor (Surat/Dokumen) :");
        nomor.setBounds(10, 207, 180, 25);
        perihal = new JLabel("Perihal :");
        perihal.setBounds(10, 254, 80, 25);
        asal = new JLabel("Asal :");
        asal.setBounds(10, 301, 80, 25);
        penerima = new JLabel("Penerima :");
        penerima.setBounds(10, 350, 80, 25);

        letak = new JLabel("Letak Surat/Dokumen");
        letak.setBounds(350, 150, 250, 25);
        ruangan = new JLabel("* Ruangan");
        ruangan.setBounds(350, 175, 100, 25);
        lemari = new JLabel("* Lemari");
        lemari.setBounds(350, 200, 100, 25);
        loker = new JLabel("* Loker");
        loker.setBounds(350, 225, 100, 25);

        jenis = new JLabel("Jenis:");
        jenis.setBounds(10, 150, 180, 25);
        namapetugas = new JLabel("Nama Petugas :");
        namapetugas.setBounds(350, 254, 160, 25);
        tanggal = new JLabel("Tanggal :");
        tanggal.setBounds(350, 305, 80, 25);


        tnomor = new JTextField();
        tnomor.setBounds(20, 232, 250, 22);
        tperihal = new JTextField();
        tperihal.setBounds(20, 279, 250, 22);
        tasal = new JTextField();
        tasal.setBounds(20, 326, 250, 22);
        tpenerima = new JTextField();
        tpenerima.setBounds(20, 373, 250, 22);
        tnamapetugas = new JTextField();
        tnamapetugas.setBounds(350, 279, 300, 22);
        truangan = new JTextField();
        truangan.setBounds(430, 175, 220, 22);
        tlemari = new JTextField();
        tlemari.setBounds(430, 200, 220, 22);
        tloker = new JTextField();
        tloker.setBounds(430, 225, 220, 22);
        tgl = new JTextField();
        tgl.setBounds(350, 330, 200, 22);

        cancel = new JButton("Cancel");
        cancel.setBounds(460, 410, 100, 35);

        save = new JButton("Save");
        save.setBounds(570, 410, 100, 35);

        cancel.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                frame.setVisible(false);

            }
        });
        save.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                buttonSimpanAction();
               
            }
        });

    }

    public void show() {
        frame.getContentPane().add(Sekertariat);
        frame.getContentPane().add(universitas);
        frame.getContentPane().add(nomor);
        frame.getContentPane().add(tnomor);
        frame.getContentPane().add(perihal);
        frame.getContentPane().add(tperihal);
        frame.getContentPane().add(asal);
        frame.getContentPane().add(tasal);
        frame.getContentPane().add(penerima);
        frame.getContentPane().add(tpenerima);
        frame.getContentPane().add(letak);
        frame.getContentPane().add(loker);
        frame.getContentPane().add(ruangan);
        frame.getContentPane().add(lemari);
        frame.getContentPane().add(jenis);
        frame.getContentPane().add(rsurat);
        frame.getContentPane().add(rdok);
        frame.getContentPane().add(truangan);
        frame.getContentPane().add(tlemari);
        frame.getContentPane().add(tloker);
        frame.getContentPane().add(namapetugas);
        frame.getContentPane().add(tnamapetugas);
        frame.getContentPane().add(tanggal);
        frame.getContentPane().add(tgl);
        frame.getContentPane().add(cancel);
        frame.getContentPane().add(save);
        frame.getContentPane().add(logo);
        frame.getContentPane().add(background);

    }
    
    public void cancelAction() {
        tnomor.setText(null);
        tperihal.setText(null);
        tasal.setText(null);
        tpenerima.setText(null);
    }

    public void buttonSimpanAction() {
  
        String nomor = String.valueOf(tnomor.getText());
        String perihal= String.valueOf(tperihal.getText());
        String asal = String.valueOf(tasal.getText());
        String penerima = String.valueOf(tpenerima.getText());
        String loker = String.valueOf(tloker.getText());
        String lemari = String.valueOf(tlemari.getText());
        String ruangan = String.valueOf(truangan.getText());
        String petugasPenerima = String.valueOf(tnamapetugas.getText());
        String tanggl = String.valueOf(tgl.getText());
       
        if (rsurat.isSelected() == true) {
            PengendaliSuratDokumen.tambahSurat(nomor, perihal, asal, penerima, ruangan, lemari, loker , petugasPenerima,tanggl);
        } else if (rdok.isSelected() == true) {
            PengendaliSuratDokumen.tambahDokumen(nomor, perihal, asal, penerima, ruangan, lemari, loker, petugasPenerima, tanggl);
        } else {
            JOptionPane.showMessageDialog(null, "Surat atau Dokumen Harus Dipilih!");
        }
    }

     
    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                Sekretariat sek = new Sekretariat();
                sek.show();
            }
        });
    }
}
